package com.woniu.market_stall_web.config;


import com.woniu.market_stall_web.intercepters.PermissionIntercepter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //配置视图映射
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/ws.html").setViewName("ws");
        registry.addViewController("/uc.html").setViewName("uc");
        registry.addViewController("/bid.html").setViewName("bid");
        registry.addViewController("/bidding.html").setViewName("bidding");
        registry.addViewController("/win.html").setViewName("win");
        registry.addViewController("/news.html").setViewName("news");
        registry.addViewController("/no.html").setViewName("no");
        registry.addViewController("/already.html").setViewName("already");
        registry.addViewController("/detail.html").setViewName("detail");
        registry.addViewController("/edit.html").setViewName("edit");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new PermissionIntercepter())
                .addPathPatterns("/**")
                .excludePathPatterns("/","/login.html","/user/login","/user/register","/user/captcha","/handle/login") //放行用户的操作 登录
                .excludePathPatterns("/index/main","/index/resetPass","/user/update","/user/verify","/user/sendEmail2/{email}")  //放行首页访问
                .excludePathPatterns("/auctionStall/auctioning")  //放行
                .excludePathPatterns("/auctionRoom/selectRoomByStallId")  //放行
                .excludePathPatterns("/auctionRoom/selectUser")  //放行
                .excludePathPatterns("/auctionRoom/signUp")  //放行
                .excludePathPatterns("/auctionRoom/bidPrice")  //放行
                .excludePathPatterns("/auctionRoom/getWinner")  //放行
                .excludePathPatterns("/auctionRoom/updateAuctionStallStatus")  //放行
                .excludePathPatterns("/asserts/**"); //静态资源放行
    }
}
